package com.fsnbigdata.service.impl;
import com.fsnbigdata.service.api.ProductImageService;
import org.springframework.roo.addon.layers.service.annotations.RooServiceImpl;
import com.fsnbigdata.domain.Product;
import com.fsnbigdata.domain.ProductImage;
import com.fsnbigdata.repository.ProductImageRepository;
import io.springlets.data.domain.GlobalSearch;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * = ProductImageServiceImpl
 *
 * TODO Auto-generated class documentation
 *
 */
@RooServiceImpl(service = ProductImageService.class)
@Service
@Transactional(readOnly = true)
public class ProductImageServiceImpl implements ProductImageService {

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    private ProductImageRepository productImageRepository;

    /**
     * TODO Auto-generated constructor documentation
     *
     * @param productImageRepository
     */
    @Autowired
    public ProductImageServiceImpl(ProductImageRepository productImageRepository) {
        setProductImageRepository(productImageRepository);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return ProductImageRepository
     */
    public ProductImageRepository getProductImageRepository() {
        return productImageRepository;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param productImageRepository
     */
    public void setProductImageRepository(ProductImageRepository productImageRepository) {
        this.productImageRepository = productImageRepository;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param entity
     * @return ProductImage
     */
    @Transactional
    public ProductImage save(ProductImage entity) {
        return getProductImageRepository().save(entity);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return ProductImage
     */
    public ProductImage findOne(Long id) {
        return getProductImageRepository().findOne(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return ProductImage
     */
    public ProductImage findOneForUpdate(Long id) {
        return getProductImageRepository().findOneDetached(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param ids
     * @return List
     */
    public List<ProductImage> findAll(Iterable<Long> ids) {
        return getProductImageRepository().findAll(ids);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param product
     * @param globalSearch
     * @param pageable
     * @return Page
     */
    public Page<ProductImage> findByProduct(Product product, GlobalSearch globalSearch, Pageable pageable) {
        return getProductImageRepository().findByProduct(product, globalSearch, pageable);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param product
     * @return Long
     */
    public long countByProduct(Product product) {
        return getProductImageRepository().countByProduct(product);
    }

    @Override
    public List<String> getUrl(Long id) {
        return getProductImageRepository().getUrl(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Class
     */
    public Class<ProductImage> getEntityType() {
        return ProductImage.class;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Class
     */
    public Class<Long> getIdType() {
        return Long.class;
    }
}
